package sng.net.http
{
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.ByteArray;
	import flash.utils.Timer;
	
	import sng.net.http.cspkg.CSAccLoginC;
	import sng.net.http.cspkg.CSAccLoginS;
	import sng.net.http.cspkg.CSPKGMSG;
	import sng.net.http.cspkg.Macros;
	import sng.net.http.cspkg.TdrUtil;

	/**
	 *测试程序 
	 * @author leonliu
	 * 
	 */	
	public class HttpTest
	{
		
		private var _timer:Timer;
		
		
		public function HttpTest()
		{
			
//			_timer = new Timer(1000, 1);
//			
//			_timer.addEventListener(TimerEvent.TIMER, onTimer);
//			
//			_timer.start();
		}
		
		
		private function onTimer(e:Event):void
		{
			sendMsg();
		}
		
		/**
		 * 发送服务器消息 
		 * 
		 */		
		public function sendMsg():void
		{
			
			
			var csMsg:CSPKGMSG = new CSPKGMSG();
			
			
			csMsg.head.Cmd = Macros.CS_CMD_REQ_ACCOUNT_LOGIN;
			
			
			var login:CSAccLoginC = new CSAccLoginC();
			
			login.ClientIP=123123123;
			login.Uin=123456;
			var intVec:Vector.<int> = new  Vector.<int>(16, true);
			
	
			for (var Passwd_i : uint = 0; Passwd_i < 16; Passwd_i++) {
				intVec[Passwd_i] == 1;
			}
			
			login.Passwd=intVec;
			
			
			csMsg.body.reqAccLogin = login;
			
//			var logacc:CSAccLoginS=new CSAccLoginS();
//			
//			csMsg.body.resAcclogin=logacc;
			
			NetClient.instance.sendMsg(TDRUtil.instance.encode(csMsg), onServerMsg);
			
			
			/*Debug.*/trace("send msg");
			/*Debug.*/trace(csMsg);
			
		}
		
		/**
		 * 收获服务器消息 
		 * @param msg
		 * 
		 */		
		
		public function onServerMsg(buf:ByteArray):void
		{
			trace(buf);
			var csMsg:CSPKGMSG = TDRUtil.instance.decode(buf);
			///*Debug.*/trace(buf);
			/*Debug.*/trace("onServerMsg msg");
			
		}
		
	}
}